﻿using System.Collections.ObjectModel;
using CI.Models;
using CI.Services;
using CI.ViewModels.Industry;
using Microsoft.Practices.ServiceLocation;

namespace CI.ViewModels
{
    public class WelcomeSheetViewModel : CIPresenterBase
    {
        private readonly IOwnerService _ownerService = ServiceLocator.Current.GetInstance<IOwnerService>();
        private ISheetsViewModel _sheets;

        private ISheetsViewModel Sheets
        {
            get
            {
                if (_sheets == null)
                    _sheets = ServiceLocator.Current.GetInstance<ISheetsViewModel>();

                return _sheets;
            }
        }

        public WelcomeSheetViewModel()
        {
            DisplayName = "Welcome";

            Corporations = _ownerService.Corporations;
            Characters = _ownerService.Characters;
        }

        public override void Initialize()
        {
        }

        public override bool CanShutdown()
        {
            return false;
        }

        public override void Shutdown()
        {
        }

        public override void Activate()
        {
        }

        public override void Deactivate()
        {
        }

        public ObservableCollection<ICorporation> Corporations { get; private set; }
        public ObservableCollection<ICharacter> Characters { get; private set; }

        public void AddIndustrySheet()
        {
            Sheets.AddSheet(new IndustrySheetViewModel {DisplayName = "New Industry Sheet"});
        }
    }
}